package com.base.admin.context;

import com.base.admin.entity.AdminUser;
import org.springframework.stereotype.Component;

/**
 * @author rqq
 */

public class GlobalContext {
    public static ThreadLocal<AdminUser> threadLocal = new ThreadLocal<>();

    public static void set(AdminUser adminUser) {
        threadLocal.set(adminUser);
    }

    public static String getUsername() {
        return threadLocal.get().getUsername();
    }

    public static AdminUser getLoginUser() {
        return threadLocal.get();
    }

    public static void remove() {
        threadLocal.remove();
    }
}
